package com.rt.cms.controller.system;

import com.rt.cms.common.Constants;
import com.rt.cms.data.dto.system.UserDto;
import com.rt.cms.data.entity.system.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * Create with IDEA
 *
 * @author Wangzs
 * @Description
 * @Date 2018/6/12
 * @Time 10:00
 */
@Controller
@RequestMapping("/header")
public class HeaderController {

    @RequestMapping(method = RequestMethod.GET)
    public String personalInfo(HttpServletRequest request, Model model){
        User user = (User) request.getAttribute(Constants.CURRENT_USER);
        UserDto userDto = new UserDto(user);
        switch (user.getUserType()){
            case "0":
                userDto.setUserType("档案组员");
                break;
            case "1":
                userDto.setUserType("档案组长");
                break;
            case "2":
                userDto.setUserType("审核员");
                break;
            case "3":
                userDto.setUserType("管理员");
                break;
            default:
                userDto.setUserType("你是谁？");
        }
        model.addAttribute("personal",userDto);
        return "system/personalInfo";
    }

}
